#include <iostream>
using namespace std;
bool constraint(int *v,int k)
{
	for (int i=1;i<=k;i++)
	{
		for (int j=1;j<i;j++)
		{
			if (v[i]==v[j]||v[j]-v[i]==j-i||v[j]-v[i]==i-j)
			{
				return false;
			}
		}
	}
	return true;
}
void Queens(int number,int k,int &found,int *v)
{
	for (int i=1;i<=number;i++)
	{
		v[k]=i;
		//cout<<"v[k]"
		if (constraint(v,k))
		{
			if (k==number)
			{
				
				cout<<"RESULT"<<++found<<":";
				for (i=1;i<=number;i++)
				{
					cout<<v[i];
				}
				cout<<endl;
			}
			else
				Queens(number,k+1,found,v);

		}
	}
}
void main()
{
	int n;
	int *v;
	cout<<"how many queens are there"<<endl;
	cin>>n;
	v=new int[n+1];
	int found=0;
	Queens(n,1,found,v);
	//cout<<found<<endl;
}
